﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace Daphne.Forms
{
    /// <summary>
    /// Interaction logic for Splash.xaml
    /// </summary>
    public partial class Splash : Window
    {
        private const string _sPicture = "AppData\\Pictures\\daphne.jpg";
        private const int _numSeconds = 2;
        private DispatcherTimer _timer;

        public Splash()
        {
            InitializeComponent();

            string sPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            BitmapSource bs = new BitmapImage(new Uri(System.IO.Path.Combine(sPath, _sPicture)));

            this.WindowStyle = System.Windows.WindowStyle.None;
            this.Width = bs.PixelWidth;
            this.Height = bs.PixelHeight;

            uxSplash.Source = bs;

            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, _numSeconds);
            _timer.Tick += _timer_Tick;
            _timer.Start();
        }

        void _timer_Tick(object sender, EventArgs e)
        {
            _timer.Stop();
            this.Close();
        }
    }
}
